package mtn.bowen.yan.server.service.impl;

import mtn.bowen.yan.server.dao.WeekRecipeDao;
import mtn.bowen.yan.server.model.VarietyDishes;
import mtn.bowen.yan.server.model.WeekRecipe;
import mtn.bowen.yan.server.service.WeekRecipeService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author <a href=mailto:yanbowen90@foxmail.com> bowen.yan </a>
 * @version 1.0
 * @description: TODO
 * @date 2021-10-30 11:53 AM
 */
@Component
public class WeekRecipeServiceImpl implements WeekRecipeService {

    private final static Logger LOGGER = LoggerFactory.getLogger(WeekRecipeServiceImpl.class);

    @Resource
    private WeekRecipeDao weekRecipeDao;

    /**
     * 根据星期、类型、种类查询食谱
     *
     * @param varietyDishes 星期、类型、种类
     * @return 查询食谱结果集合
     */
    @Override
    public List<WeekRecipe> selectByWeekAndTypeAndKind(VarietyDishes varietyDishes) {

        return weekRecipeDao.selectByWeekAndTypeAndKind(varietyDishes.getWeek(), varietyDishes.getType(), varietyDishes.getKind());
    }

    /**
     * 根据星期、类型、种类删除食谱
     *
     * @param varietyDishes 星期、类型、种类
     * @return 执行删除数据条数
     */
    @Override
    public int deleteByVarietyDishes(VarietyDishes varietyDishes) {
        return weekRecipeDao.deleteByWeekAndTypeAndKind(varietyDishes.getWeek(), varietyDishes.getType(), varietyDishes.getKind());
    }

    /**
     * 根据星期、类型、种类删除食谱
     *
     * @param week 星期
     * @param type 类型
     * @param kind 种类
     * @return 结果结合
     */
    @Override
    public int deleteByWeekAndTypeAndKind(int week, int type, int kind) {
        return weekRecipeDao.deleteByWeekAndTypeAndKind(week, type, kind);
    }

    @Override
    public int insertWeekRecipe(WeekRecipe weekRecipe) {
        return weekRecipeDao.insertWeekRecipe(weekRecipe);
    }

    /**
     * 根据星期、类型 查询食谱
     *
     * @param week 星期
     * @param type 类型
     * @return 查询食谱结果集合
     */
    @Override
    public List<WeekRecipe> selectByWeekAndType(int week, int type) {

        return weekRecipeDao.selectByWeekAndType(week, type);
    }
}
